import React, { Component } from 'react'

export default class CallbackCom extends Component {

  show = () => {
    //获取input的文本
    let v = this.input.value;
    //设置div的文本
    this.div.innerHTML = v;
  }

  render() {
    return (
      <div>
        <input type="text" ref={(el) => {
          //将真实 DOM 节点对象保存在实例的身上
          this.input = el;
        }}  /><button onClick={this.show}>展示</button>
        <hr />
        <div ref={el => this.div = el} style={{width: 400, height: 300, border: 'solid 1px #345'}}>

        </div>
      </div>
    )
  }
}
